import { ServerUrl } from "../utils/request";
import qs from 'qs';
import type {
  MLoginFormState,
  MGetInfoParams,
  MAddProjectFormState,
  MAllProjectsParams,
  MDeleteProjectsParams,
  MGetByIdParams,
  MGetListParams,
  MDeleteTopologyParams,
  MAddTopologyFormState,
  MAddTopologyConfigState,
} from '../utils/interface';

const _user = {
  login: '/sys_user/login',
  logout: '/sys_user/logout',
}

const _project = {
  info: '/project/info',
  allProjects: '/project/allProjects',
  saveProject: '/project/saveProject',
  deleteProjects: '/project/deleteProjects',
}

const _topology = {
  getById: '/topology/getById',
  list: '/topology/list',
  saveTopology: '/topology/saveTopology',
  saveTopologyConfiguration: '/topology/saveTopologyConfiguration',
  delete: '/topology/delete'

}

const Login = (params: MLoginFormState) => {return ServerUrl({url: _user.login, method: 'post', data: params})};
const Logout = () => {return ServerUrl({url: _user.logout, method: 'post'})};

const Info = (params: MGetInfoParams) => {return ServerUrl({url: _project.info, method: 'get', params})};
const SaveProject = (params: MAddProjectFormState) => {return ServerUrl({url: _project.saveProject, method: 'post', data: params})};
const AllProjects = (params: MAllProjectsParams) => {return ServerUrl({url: _project.allProjects, method: 'post', data: params})};
const DeleteProjects = (params: MDeleteProjectsParams) => {return ServerUrl({url: _project.deleteProjects, method: 'delete', data: params})};

const GetById = (params: MGetByIdParams) => {return ServerUrl({url: _topology.getById, method: 'get', params})};
const List = (params: MGetListParams) => {return ServerUrl({url: _topology.list, method: 'get', params})};
const SaveTopology = (params: MAddTopologyFormState) => {return ServerUrl({url: _topology.saveTopology, method: 'post', data: params})};
const DeleteTopology = (params: MDeleteTopologyParams) => {return ServerUrl({url: _topology.delete, method: 'delete', data: params})};
const SaveTopologyConfiguration = (params: MAddTopologyConfigState) => {return ServerUrl({url: _topology.saveTopologyConfiguration, method: 'post', data: params})};


export {
  Login,
  Logout,
  Info,
  SaveProject,
  AllProjects,
  DeleteProjects,
  GetById,
  List,
  DeleteTopology,
  SaveTopology,
  SaveTopologyConfiguration,
}